//
// Created by wkm on 2024-03-17.
//

#include "ShiftRows.h"

//定义行移位操作：行左循环移位
void ShiftRows(unsigned char *col) {//正向行移位
    unsigned char t;
    //左移1位
    t = col[1];
    col[1] = col[5];
    col[5] = col[9];
    col[9] = col[13];
    col[13] = t;
    //左移2位，交换2次数字来实现
    t = col[2];
    col[2] = col[10];
    col[10] = t;
    t = col[6];
    col[6] = col[14];
    col[14] = t;
    //左移3位，相当于右移1次
    t = col[15];
    col[15] = col[11];
    col[11] = col[7];
    col[7] = col[3];
    col[3] = t;
    //第4行不移位
}

//逆向行移位
void Contrary_ShiftRows(unsigned char *col) {
    unsigned char t;
    t = col[13];
    col[13] = col[9];
    col[9] = col[5];
    col[5] = col[1];
    col[1] = t;
    t = col[2];
    col[2] = col[10];
    col[10] = t;
    t = col[6];
    col[6] = col[14];
    col[14] = t;
    t = col[3];
    col[3] = col[7];
    col[7] = col[11];
    col[11] = col[15];
    col[15] = t;
    //同理，第4行不移位
}